import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xvideos/hj_page/mine_business/message/message_center_sub_page.dart';
import 'package:xvideos/tools_base/widget/keep_alive_widget.dart';

import 'message_center_logic.dart';

class MessageCenterPage extends StatelessWidget {
  static const routeName = "/MessageCenterPage";
  const MessageCenterPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('消息中心',
      style: TextStyle(
              color: Color(0xE5FFFFFF),
              fontSize: 18,
              fontWeight: FontWeight.w600,
            ),)),
      body: GetBuilder<MessageCenterLogic>(
        init: MessageCenterLogic(),
        builder: (logic) {
          return Column(
            children: [
              TabBar( 
                isScrollable: true,
                labelStyle: TextStyle(
                  fontSize: 14,
                  color: Colors.white.withOpacity(.9),
                  fontWeight: FontWeight.w500,
                ),
                unselectedLabelStyle: TextStyle(
                  fontSize: 14,
                  color: Colors.white.withOpacity(.45),
                ),
                indicator: BoxDecoration(),
                tabAlignment: TabAlignment.start,
                controller: logic.tabController,
                labelPadding: EdgeInsets.symmetric(horizontal: 0),
                tabs: logic.titleArr.map((it) => Container(
                      child: Text(it),
                      padding: EdgeInsets.symmetric(horizontal: 12),
                      margin: EdgeInsets.symmetric(vertical: 12),
                      decoration: BoxDecoration(
                        border: Border(left: BorderSide(color: it == logic.titleArr.first ? Colors.transparent : Color(0x1AFFFFFF), width: 1)),
                      ),
                    )).toList(),
              ),
              Expanded(
                child: TabBarView(
                    controller: logic.tabController,
                    children: logic.titleArr
                        .asMap()
                        .map((key, value) => MapEntry(key, MessageCenterSubPage(MessageType.values[key]).keepAlive))
                        .values
                        .toList()),
              ),
            ],
          );
        },
      ),
    );
  }
}
